import {
  attributeList,
  eventList,
  actionList,
  getBasicdataListByTypeData,
  getFormMacroListSequenceData,
  getAdminListRoleByUnitCodeData,
  getFormGetFieldsOfDeptSelectCtlData,
  getLsdListData,
  getFormGetFieldsData,
} from './config';
import { deepClone } from '/@/views/formDesigner/utils';

const data = [
  {
    label: '当前用户',
    type: 'macro_current_user',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options = await getFormGetFieldsData();
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter(
        (item) => item.field != 'range' && item.field != 'description',
      );
      const fields = [
        {
          label: '性别',
          value: 'gender',
        },
        {
          label: '手机',
          value: 'mobile',
        },
        {
          label: '身份证',
          value: 'idCard',
        },
        {
          label: '地址',
          value: 'address',
        },
        {
          label: '入职时间',
          value: 'entryDate',
        },
        {
          label: '生日',
          value: 'birthday',
        },
        {
          label: '职务',
          value: 'duties',
        },
      ];
      fields.forEach((item) => {
        newAttributeList.push({
          label: item.label,
          type: 'select',
          field: item.value,
          componentProps: {
            placeholder: '请选择',
            defaultValue: '',
            showSearch: true,
            optionFilterProp: 'label',
            allowClear: true,
            // fieldNames: { label: 'title', value: 'name' },
            options: options,
          },
        });
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '当前单位名称',
    type: 'macro_current_unit',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '用户列表',
    type: 'macro_user_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '部门选择框',
    type: 'macro_dept_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '意见输入框',
    type: 'macro_opinion',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      const newAttributeList = deepClone(attributeList);
      newAttributeList.forEach((item) => {
        if (item.type == 'lenSize') {
          item.componentProps!.defaultValue = {
            minT: 'd=',
            minV: '',
            maxT: 'x=',
            maxV: 2000,
          };
        }
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '签名框',
    type: 'macro_sign',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '图片签名框',
    type: 'macro_sign_img',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '自动编号',
    type: 'macro_flow_number',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options = await getFormMacroListSequenceData();
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter((item) => item.field != 'range');
      newAttributeList.push({
        label: '序列号种类选择',
        type: 'select',
        field: 'sel',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          showSearch: true,
          optionFilterProp: 'name',
          allowClear: true,
          options,
          fieldNames: { label: 'name' },
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '图像',
    type: 'macro_image',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      const newAttributeList = deepClone(attributeList);
      newAttributeList.push({
        label: '宽度',
        type: 'number',
        field: 'width',
        componentProps: {
          placeholder: '',
          defaultValue: '',
          allowClear: true,
          addonAfter: 'px',
        },
      });
      newAttributeList.push({
        label: '高度',
        type: 'number',
        field: 'height',
        componentProps: {
          placeholder: '',
          defaultValue: '',
          allowClear: true,
          addonAfter: 'px',
        },
      });
      newAttributeList.push({
        label: '大小',
        type: 'number',
        field: 'maxSize',
        componentProps: {
          placeholder: '',
          defaultValue: '',
          allowClear: true,
          addonAfter: 'KB',
        },
      });
      newAttributeList.push({
        label: '拍照',
        type: 'switch',
        field: 'isOnlyCamera',
        describe: '手机端只允许拍照，不能选择照片上传',
        componentProps: {
          checkedValue: '1',
          unCheckedValue: '0',
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '文件',
    type: 'macro_attachment',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: 'SQL控件',
    type: 'macro_sql',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '基础数据选择',
    type: 'macro_flow_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options: any = await getBasicdataListByTypeData(false);
      let newAttributeList = deepClone(attributeList);
      // 使description不显示
      // newAttributeList.forEach((item) => {
      //   if (item.field == 'description') {
      //     item.show = false;
      //   }
      // });
      // 过滤掉description
      newAttributeList = newAttributeList.filter((item) => item.field != 'description');
      newAttributeList.push({
        label: '基础数据',
        type: 'select',
        field: 'sel',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          showSearch: true,
          optionFilterProp: 'name',
          options,
          fieldNames: { label: 'name' },
        },
      });
      newAttributeList.push({
        label: '可选层级',
        type: 'select',
        field: 'layer',
        describe: '仅对树形基础数据有效',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          options: [
            {
              label: '不限',
              value: '',
            },
            {
              label: '1级',
              value: '1',
            },
            {
              label: '末级',
              value: '0',
            },
          ],
        },
      });
      newAttributeList.push({
        label: '请求参数',
        type: 'input',
        field: 'requestParam',
        describe: '默认为字段名',
        componentProps: {
          placeholder: '默认为字段名',
          defaultValue: '',
          allowClear: true,
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '嵌套表格',
    type: 'nest_table',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      // 过滤掉description
      newAttributeList = newAttributeList.filter((item) => item.field != 'description');
      newAttributeList.push({
        label: '编辑',
        type: 'nestSheet',
        field: 'macroProps',
        componentProps: {
          mode: 'nest_table',
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  // {
  //   label: '嵌套表单',
  //   type: 'nest_form',
  //   attributeDefaultValue: '',
  //   icon: 'epic-icon-write',
  //   input: true,
  //   component: () => import('ant-design-vue/lib/input'),
  //   bindModel: 'modelValue',
  //   getAttributeList: () => {
  //     const newAttributeList = deepClone(attributeList);
  //     newAttributeList.push({
  //       label: '表单',
  //       type: 'select',
  //       field: 'sel',
  //       componentProps: {
  //         placeholder: '请选择',
  //         defaultValue: '',
  //         allowClear: true,
  //         options: [
  //           {
  //             label: '无',
  //             value: '',
  //           },
  //         ],
  //       },
  //     });

  //     return newAttributeList;
  //   },
  //   getEventList: eventList,
  //   getActionList: actionList,
  // },
  {
    label: '嵌套表格2',
    type: 'nest_sheet',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      // 过滤掉description
      newAttributeList = newAttributeList.filter((item) => item.field != 'description');
      newAttributeList.push({
        label: '编辑',
        type: 'nestSheet',
        field: 'macroProps',
        componentProps: {
          mode: 'nest_sheet',
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '小写转大写控件',
    type: 'lowerToUpper',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '表单域选择窗体',
    type: 'module_field_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      // 过滤掉description
      newAttributeList = newAttributeList.filter((item) => item.field != 'description');
      newAttributeList.push({
        label: '编辑',
        type: 'moduleFieldSelect',
        field: 'macroProps',
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '省份选择框',
    type: 'macro_province_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '城市选择框',
    type: 'macro_city_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '区县选择框',
    type: 'macro_country_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '角色中用户选择框',
    type: 'role_user_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options: any = await getAdminListRoleByUnitCodeData();

      const newAttributeList = deepClone(attributeList);
      newAttributeList.forEach((item) => {
        if (item.field == 'description') {
          item.show = false;
        }
      });
      newAttributeList.push({
        label: '角色选择',
        type: 'select',
        field: 'sel',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          options,
          showSearch: true,
          optionFilterProp: 'name',
          fieldNames: {
            label: 'name',
          },
        },
      });

      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '富文本编辑器',
    type: 'macro_ueditor',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter((item) => item.field != 'range');
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '标值控件',
    type: 'macro_raty',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '角色选择框',
    type: 'macro_role_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '用户所在部门选择框',
    type: 'macro_my_dept_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '用户选择框',
    type: 'macro_user_select_win',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options = await getFormGetFieldsData();
      options.forEach((item) => {
        delete item.props;
        delete item.options;
      });

      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter((item) => item.field != 'range');

      newAttributeList.push({
        label: '',
        type: 'divider',
        field: 'divider',
        componentProps: {
          placeholder: '属性',
          allowClear: true,
          orientation: 'center',
        },
      });
      newAttributeList.push({
        label: '默认当前用户',
        type: 'select',
        field: 'isCurrent',
        componentProps: {
          placeholder: '请选择',
          defaultValue: 'false',
          allowClear: true,
          options: [
            {
              label: '是',
              value: 'true',
            },
            {
              label: '否',
              value: 'false',
            },
          ],
        },
      });

      const optionsDept = await getFormGetFieldsOfDeptSelectCtlData();
      console.log('optionsDept', optionsDept);
      newAttributeList.push({
        label: '联动部门字段',
        type: 'select',
        field: 'deptField',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          options: [
            {
              title: '无',
              name: '',
            },
            ...optionsDept,
          ],
          fieldNames: {
            label: 'title',
            value: 'name',
          },
        },
      });
      newAttributeList.push({
        label: '',
        type: 'divider',
        field: 'divider',
        componentProps: {
          placeholder: '映射字段',
          allowClear: true,
          orientation: 'center',
        },
      });
      const fields = [
        {
          label: '性别',
          value: 'gender',
        },
        {
          label: '手机',
          value: 'mobile',
        },
        {
          label: '身份证',
          value: 'idCard',
        },
        {
          label: '地址',
          value: 'address',
        },
        {
          label: '入职时间',
          value: 'entryDate',
        },
        {
          label: '生日',
          value: 'birthday',
        },
        {
          label: '职务',
          value: 'duties',
        },
      ];
      fields.forEach((item) => {
        newAttributeList.push({
          label: item.label,
          type: 'select',
          field: item.value,
          componentProps: {
            placeholder: '请选择',
            defaultValue: '',
            allowClear: true,
            showSearch: true,
            options: [
              // {
              //   label: '无',
              //   value: '',
              // },
              ...options,
            ],
          },
        });
      });

      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '多用户选择框',
    type: 'macro_user_multi_select_win',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '定位宏控件',
    type: 'macro_location_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '定位宏控件(天地图)',
    type: 'macro_location_td_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '文件组',
    type: 'macro_attachments',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '部门选择窗体',
    type: 'macro_dept_sel_win',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '文件柜目录选择框',
    type: 'macro_fileark_dir_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '流程控件',
    type: 'macro_workflow_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '文号头选择框',
    type: 'macro_paperno_select',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '文号控件',
    type: 'macro_paperno_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '超链接控件',
    type: 'macro_hyperlink_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '年份宏控件',
    type: 'macro_year_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter((item) => item.field != 'range');
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  // {
  //   label: '颜色选择下拉框',
  //   type: 'macro_color_select',
  //   attributeDefaultValue: '',
  //   icon: 'epic-icon-write',
  //   input: true,
  //   component: () => import('ant-design-vue/lib/input'),
  //   bindModel: 'value',
  //   getAttributeList: attributeList,
  //   getEventList: eventList,
  //   getActionList: actionList,
  // },
  {
    label: '当前用户岗位宏控件',
    type: 'macro_post',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '岗位列表宏控件',
    type: 'macro_post_list',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '月份宏控件',
    type: 'macro_month_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter((item) => item.field != 'range');
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '标注宏控件',
    type: 'macro_location_mark_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '标注宏控件(天地图)',
    type: 'macro_location_mark_td_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '颜色宏控件',
    type: 'macro_color_picker_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '高级颜色宏控件',
    type: 'macro_color_picker_pro_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '多部门选择宏控件',
    type: 'macro_moredeptctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '流程类型',
    type: 'macro_flow_type',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '脚本设计器',
    type: 'macro_script_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '函数宏控件',
    type: 'macro_formula_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      // 过滤掉description
      newAttributeList = newAttributeList.filter((item) => item.field != 'description');
      newAttributeList.push({
        label: '编辑',
        type: 'macroFormulaCtl',
        field: 'macroProps',
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '邮箱宏控件',
    type: 'macro_email_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '手机号宏控件',
    type: 'macro_mobile_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '身份证宏控件',
    type: 'macro_idcard_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '手写板宏控件',
    type: 'macro_writepad_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter(
        (item) => item.field != 'range' && item.field != 'dataType' && item.field != 'value',
      );
      newAttributeList.push({
        label: '宽度',
        type: 'number',
        field: 'width',
        componentProps: {
          placeholder: '',
          defaultValue: '',
          allowClear: true,
          addonAfter: 'px',
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '图标宏控件',
    type: 'macro_icon_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: () => {
      let newAttributeList = deepClone(attributeList);
      newAttributeList = newAttributeList.filter((item) => item.field != 'range');
      // 过滤掉description
      newAttributeList = newAttributeList.filter((item) => item.field != 'description');
      newAttributeList.push({
        label: '编辑',
        type: 'macroIconCtl',
        field: 'macroProps',
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '引用字段控件',
    type: 'macro_quote_field_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '双重引用字段控件',
    type: 'macro_quote_double_field_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '系统菜单',
    type: 'macro_menu_select_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '图标字体',
    type: 'macro_icon_font_select_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '模块选择框',
    type: 'macro_module_select_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '条形码宏控件',
    type: 'macroType-result-3fe2-macro_barcode',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '可视化上传控件',
    type: 'macro_uploader_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '树形部门选择框',
    type: 'macro_dept_tree_select_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '树形基础数据选择框',
    type: 'macro_basic_tree_select_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options: any = await getBasicdataListByTypeData();
      const newAttributeList = deepClone(attributeList);
      newAttributeList.push({
        label: '基础数据',
        type: 'select',
        field: 'sel',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          options,
          fieldNames: { label: 'name' },
        },
      });
      newAttributeList.push({
        label: '可选层级',
        type: 'select',
        field: 'layer',
        describe: '仅对树形基础数据有效',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          options: [
            {
              label: '不限',
              value: '',
            },
            {
              label: '1级',
              value: '1',
            },
            {
              label: '末级',
              value: '0',
            },
          ],
        },
      });
      newAttributeList.push({
        label: '请求参数',
        type: 'input',
        field: 'requestParam',
        describe: '默认为字段名',
        componentProps: {
          placeholder: '默认为字段名',
          defaultValue: '',
          allowClear: true,
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '二维码宏控件',
    type: 'macro_qrcode',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '进度条宏控件',
    type: 'macro_progress_bar_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '时间轴宏控件',
    type: 'macro_timeline_ctl',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    component: () => import('ant-design-vue/lib/input'),
    bindModel: 'value',
    getAttributeList: attributeList,
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '图片',
    type: 'static_img',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    componentProps: {
      notLabel: true,
    },
    component: () => import('../imgSelect/index.vue'),
    bindModel: 'modelValue',
    getAttributeList: async () => {
      const options = await getLsdListData();
      const newAttributeList = [
        {
          label: 'ID',
          type: 'input',
          field: 'fieldId',
          componentProps: {
            placeholder: '必填项',
            require: true,
          },
        },
        {
          label: '标签名称',
          type: 'input',
          field: 'label',
          componentProps: {
            placeholder: '必填项',
            require: true,
          },
        },
        {
          label: '标题行',
          type: 'switch',
          field: 'isTitle',
          componentProps: {
            defaultValue: false,
            checkedValue: true,
            unCheckedValue: false,
          },
        },
        {
          label: '位置',
          type: 'select',
          field: 'align',
          componentProps: {
            placeholder: '按钮位置',
            defaultValue: 'center',
            options: [
              {
                label: '居左',
                value: 'left',
              },
              {
                label: '居中',
                value: 'center',
              },
              {
                label: '居右',
                value: 'right',
              },
            ],
          },
        },
        {
          label: '显示',
          type: 'switch',
          field: 'isShow',
          componentProps: {
            defaultValue: true,
            checkedValue: true,
            unCheckedValue: false,
          },
        },
      ];
      newAttributeList.push({
        label: '图片',
        type: 'TreeSelect',
        field: 'img',
        bindModel: 'value',
        componentProps: {
          placeholder: '请选择',
          defaultValue: '',
          allowClear: true,
          treeData: options,
          showSearch: true,
          treeNodeFilterProp: 'label',
          dropdownStyle: { maxHeight: '400px', overflow: 'auto' },
        },
      });
      return newAttributeList;
    },
    getEventList: eventList,
    getActionList: actionList,
  },
  {
    label: '文本',
    type: 'static_text',
    attributeDefaultValue: '',
    icon: 'epic-icon-write',
    input: true,
    componentProps: {
      notLabel: true,
    },
    component: () => import('../textView/index.vue'),
    bindModel: 'modelValue',
    getAttributeList: [
      {
        label: 'ID',
        type: 'input',
        field: 'fieldId',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '标签名称',
        type: 'input',
        field: 'label',
        componentProps: {
          placeholder: '必填项',
          require: true,
        },
      },
      {
        label: '标题行',
        type: 'switch',
        field: 'isTitle',
        componentProps: {
          defaultValue: false,
          checkedValue: true,
          unCheckedValue: false,
        },
      },
      {
        label: '位置',
        type: 'select',
        field: 'align',
        componentProps: {
          placeholder: '按钮位置',
          defaultValue: 'center',
          options: [
            {
              label: '居左',
              value: 'left',
            },
            {
              label: '居中',
              value: 'center',
            },
            {
              label: '居右',
              value: 'right',
            },
          ],
        },
      },
      {
        label: '显示',
        type: 'switch',
        field: 'isShow',
        componentProps: {
          defaultValue: true,
          checkedValue: true,
          unCheckedValue: false,
        },
      },
    ],
    getEventList: eventList,
    getActionList: actionList,
  },
];
let comList: any = [];
comList = Promise.all(
  data.map(async (item: any) => {
    // if (item.attributeDefaultValue) {
    // }
    let attribute = [];
    if (item.getAttributeList instanceof Promise) {
      attribute = await item.getAttributeList();
    } else if (typeof item.getAttributeList == 'function') {
      attribute = await item.getAttributeList();
    } else {
      attribute = item.getAttributeList;
    }
    const newComponentProps = item.componentProps || {};
    return {
      component: item.component,
      defaultSchema: {
        ...item,
        label: item.label,
        type: item.type,
        field: item.type,
        icon: item.icon,
        input: item.input,
        componentProps: {
          ...newComponentProps,
          bordered: true,
          placeholder: '请输入',
          defaultValue: `宏控件：${item.label}`,
        },
      },
      config: {
        attribute,
        event: [
          ...(typeof item.getEventList == 'function' ? item.getEventList() : item.getEventList),
        ],
        action: [
          ...(typeof item.getActionList == 'function' ? item.getActionList() : item.getActionList),
        ],
      },
      bindModel: item.bindModel,
    };
  }),
);

export { comList };
